<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/jsp/common/taglib.jsp"%>
<div class="col-sm-12">
	<div class="content-15"> 
		<div class="col-sm-12 header lighter no-padding-top">
		    <h5 class="no-margin-top">编辑${table.comment!}</h5>
        </div>
		<div class="row">
	        <form class="form-horizontal" role="form" id="${vo?uncap_first}Form">
				<#list table.fields as field>
					<div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="${field.propertyName}"> <i style="color: red;">*</i> <#if field.comment??>${field.comment}<#else>${field.propertyName}</#if></label>
						<div class="col-sm-6">
<#if field.type == 'date'>
							<input type="text" id="${field.propertyName}" name="${field.propertyName}" value="<fmt:formatDate value='${r'$'}{${table.voPath}.${field.propertyName}}' pattern='yyyy-MM-dd'/>" class="col-xs-10 col-sm-5" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
<#elseif field.type == 'datetime' || field.type == 'timestamp'>
							<input type="text" id="${field.propertyName}" name="${field.propertyName}" value="<fmt:formatDate value='${r'$'}{${table.voPath}.${field.propertyName}}' pattern='yyyy-MM-dd HH:mm:ss'/>" class="col-xs-10 col-sm-5" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
<#else>
							<input type="text" id="${field.propertyName}" name="${field.propertyName}" value="${r'$'}{${table.voPath}.${field.propertyName}}" class="col-xs-10 col-sm-5" <#if field.type?contains('(')> maxlength="${(field.type?replace(')',''))?split('(')[1]}"</#if>/>
</#if>
							<span class="help-inline col-xs-12 col-sm-7">
								<span class="middle" style="color: red" id="${field.propertyName}_msg"></span>
							</span>
						</div>
					</div>
				</#list>
				<div class="col-xs-12">
					<div class="text-center ">
						<button class="btn btn-info" id="${vo?uncap_first}SaveBut1" type="button" onclick="add${vo}(1)">
							保存
						</button>
						<button class="btn btn-info" id="${vo?uncap_first}SaveBut0" type="button" onclick="add${vo}(0)">
							保存并退出
						</button>
						<button class="btn btn-primary" type="button" onclick='loadOther("${r'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/view.action?<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>=${r'$'}{${vo?uncap_first}.<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>}")' >
							取消
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	function add${vo}(type) {
		$.ajax({
				type: 'POST',
				dataType: 'json',
				url: "${r'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/update.action",
				data: $("#${vo?uncap_first}Form").serialize(),
				success: function (rs) {
					if (rs != null) {
						if (type == 1) {
							loadOther("${'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/edit.action?<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>=${r'$'}{${vo?uncap_first}.<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>}");
						} else {
                        	loadOther("${'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/view.action?<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>=${r'$'}{${vo?uncap_first}.<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>}");
						}
                    } else {
						bootbox.alert("操作失败!");
					}
				},
				error: function () {
					bootbox.alert("操作失败!");
				}, complete: function () {
					$("#${vo?uncap_first}SaveBut").removeAttr("disabled");
				}
			});
	}
</script>
